package day8.problem3;

//字母收集
//https://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1?tpId=230&tqId=38954&ru=/exam/oj

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        String[] strs = new String[n];
        for(int i = 0; i<n; i++) {
            strs[i] = in.next();
        }
        int[][] dp = new int[n+1][m+1];
        for(int i = 1; i<=n; i++) {
            for(int j = 1; j<=m; j++) {
                char ch = strs[i-1].charAt(j-1);
                int x = 0;
                if(ch == 'l') x = 4;
                else if(ch == 'o') x = 3;
                else if(ch == 'v') x = 2;
                else if(ch == 'e') x = 1;
                dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]) + x;
            }
        }
        System.out.println(dp[n][m]);
    }
}